Explaining programs reliably
نویسنده
چکیده
Science isaboutflndingbetter explanations [3],andto dosoitisguidedby ‰sthetics, such asOccam’sRazor, anda conviction thatrealit y isflxed.Incomputerscience,instead, we buildtheobjects we explain, andwe changethem.Computerscience, then,isaboutflnding betterexplanations forthingsthatcanbe changedto helpimprovetheexplanations. A allthemetresofpapercomputerbooksshow,thereisa highdemandeven forconventional explanations, tosay nothingofthereliable, timelyand parsimonious explanations | often innovelformats| required by usersofembeddedsystems,such asflghterpilots . Computerscien tists writeprogramsandexplain programs| whethertodocumentthemforotherprogrammers,toexplain them inthecomputerscience literature,ortowritemanualsorhelpforusers.Allthese activities nvolve manualinterv ention,typically using wordprocessors: whenpossible improvementsarespotted,theauthororauthorsrevise thedocuments.Since allthedocumentsina particular p ojectarerelated, a lotoftextinthevarious documentsissimilar ifnot exactly thesame. Elsewhere we have discussed writing bettermanuals forusers[1,6,7];wehavealsodiscussed theuseful impactofqualit y explanation programminglanguage design[12]and on physical devicedesign[14].Inthis paper,we areconcerned withwriting betterexplanationsforprograms. ProgramsareusuallywritteninplainASCII text but documentationusuallyhasa specialform. Ifa WYSIWYG wordprocessor isused,programcodementioned needsediting toflxthefont,alignmen t,pointsize andsoon;ifamark-uplanguage (lik eHTML orLTEX) isused,thenvarious programsymbolsneedconverting tothemark-uplanguage’s conventionsothattheycan appearproperly . Forexample,thesymbol& hastobe editedto&forHTML orto\& forLTEX | and ofcoursethismark-upisno longervalidinprograms, soaccurate conversion todocumentation cannotreadily beconflrmedwitha compiler. Thus,typically ,a fragmen t ofprogramcode iscutand-pasted froma workingprogramintothedocumentation, anditisthenedited carefully toconformtothe documentation system’s requiremen ts(andtothetypographical requiremen ts,particularly linelengthandindentation). Laterachangeismade,say,intheprogram. Butthisistheflrstofseveralchangesanticipated, soit perhapsisn’t worthgoingtothetrouble ofcutting-andpasting-and-editing again.Ma ybeitseemseasier totry toduplicate changesinthepreviously prepared text? Ifthereisany hurdletomakingchanges,eventually notallofthemwillbemade.Managingdocumentsand programsisnormallysuch hardworkthateither improvementsdo notgetmade,orchangesdo getmade (say tothedocumentation) butarenotaccurately re°ectedeverywherelse(say intheprogram). Forexample,thedocumentation mightreadbetterifa name is changed...thisisthethinendofthewedge,andasubtlethreatointegrit y.Reliable writing hastobemade soeasythatthereisnevera temptation toavoidimprovingbothcodeanddocumentation consisten tly .For onceevena fewdiscrepancies accummulate, itbecomes an evenharderexercise torestore integrit y. To ensuredocuments are reliable, despitebeing editedby hand,itmakessensetosharecommon text asm uch aspossible automatically . Apartfromgeneratinghighqualit y documents,thekeyidea,then,isto make itveryeasytokeeptogether andmaintainwhat arenormally separate | andsometimes increasingly independent!| documents.Shared textshouldonlybe edite d inoneplac e. Variousolutions tothisproblem have beenproposed,and allhave considerable advantagesoverapproac hingtheprocessmanually . Literate programmingwasintroducedby Knuth[5, 11]tocombineprogramsand theirdocumentationto createreadable programs.Numerousprogramshave beenpreparedusingliterate programming:sizable examplesincludeKnuth’sown outstanding books [4]. Thereisno duplication feither code ordocumentation:literate programminginterlea vestheminoneflle,
منابع مشابه
Explaining code for publication
The computer science literature discusses code and algorithms extensively, but not always reliably. Tool support can help ensure integrity between code and explanation so that published papers are more reliable. A versatile, light-weight tool to support explaining code for publication is justified, described and compared with alternatives. The tool works with Java, C and similar languages, and ...
متن کاملThe Role of Azeri Radio World Service in Explaining the Common History of Iran and The Republic of Azerbaijan
The current politico-cultural trends in the Republic of Azerbaijan, focused on "historical strangeness with Iran", have led to its divergence from Iran. One of the missions of Iranian Radio Azeri World Service is to explain the historical connections and raptures to the public opinion of its northern neighbor. Applying agenda setting and framing theories, the aim of this article is to evaluate ...
متن کاملExplaining Transition Systems through Program Induction
Explaining and reasoning about processes which underlie observed black-box phenomena enables the discovery of causal mechanisms, derivation of suitable abstract representations and the formulation of more robust predictions. We propose to learn high level functional programs in order to represent abstract models which capture the invariant structure in the observed data. We introduce the π-mach...
متن کاملProfiling optimised Haskell : causal analysis and implementation
At the present time, performance optimisation of real-life Haskell programs is a bit of a “black art”. Programmers that can do so reliably are highly esteemed, doubly so if they manage to do it without sacrificing the character of the language by falling back to an “imperative style”. The reason is that while programming at a high-level does not need to result in slow performance, it must rely ...
متن کاملIdentifying and explaining the effects of drought in rural areas in Iran from viewpoints of farmers (Case Study: Esfejin village, Zanjan county)
The main purpose of this study was to identify and explain the effects of drought in rural areas of Iran. The statistical population of this study consisted of all the heads of households of Esfejin village in Zanjan County (N = 2932). A sample of 340 persons was selected using a method of simple random sampling. Data were collected from face-to-face interviews with respondents based on a...
متن کامل